home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / gprim / discgrp / dgconstraint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-28  |  1000 b   |  45 lines

  1. #include "discgrpP.h"
  2.  
  3. static int constraint_depth;
  4. static float constraint_stored, constraint_printd;
  5.  
  6. void
  7. DiscGrpInitStandardConstraint(int depth, float ind0, float ind1)
  8. {
  9.     constraint_depth = depth;
  10.     constraint_stored = ind0;
  11.     constraint_printd = ind1;
  12. }
  13.  
  14.     static HPoint3 origin = {0.0, 0.0, 0.0, 1.0};
  15. int
  16. DiscGrpStandardConstraint(DiscGrpEl *dgel)
  17. {
  18.      int big=0, l;
  19.     float d;
  20.     HPoint3 image;
  21.     int metric = dgel->attributes & DG_METRIC_BITS;
  22.     extern double getnorm();
  23.     
  24.     if ((l = strlen(dgel->word)) > constraint_depth) 
  25.         return(DG_CONSTRAINT_LONG);
  26.     if (l == constraint_depth) big |= DG_CONSTRAINT_MAXLEN;
  27.  
  28.     /* find hyperbolic distance of image from origin: take short cut */
  29.     HPt3Transform(dgel->tform, &origin, &image);
  30.     d = HPt3SpaceDistance(&origin, &image, metric);
  31.  
  32.     if ( d < constraint_stored)    {
  33.         big |= DG_CONSTRAINT_STORE;
  34.         if ( d < constraint_printd)    {
  35.             big |= DG_CONSTRAINT_PRINT;
  36.         }
  37.         }
  38.     else        {    
  39.         big |= DG_CONSTRAINT_TOOFAR;
  40.         }
  41.         
  42.     return(big);
  43. }
  44.  
  45.